<template>
<div>
    <meta title="登录页面管理">
    </meta>
    <ManageTable border stripe :rowKey="tableData.rowKey" :columns="tableData.columns" :data="tableData.data" :btnGroup="tableData.btnGroup" :page="tableData.page">
    </ManageTable>

</div>
</template>

<script>
import moment from "moment";
import AppFrame from "../../../libs/app-frame";
import ManageTable from "../../../components/manage-table";
export default {
    data() {
        return {
             CurUserInfo: {},
            tableData: {
                rowKey: "ct_id",
                columns: [{
                        type: "selection",
                        width: 60,
                        align: "center",
                        able: '禁止删除'
                    },
                    {
                        title: "名称",
                        key: "ct_title",
                        ellipsis: true,
                        filterType: "text"
                    },
                    {
                        title: "标记",
                        width: 150,
                        key: "ct_sign",
                        filterType: "text"
                    },
                    {
                        title: "所属企业",
                        key: "iframe_orgstruct.OS_Name",
                        width: 200,
                        sortKey: "UserOrgStructID",
                        sortable: "custom",
                        filterKey: "ct_org_id",
                        filterType: "selectTree",
                        filterOptions: [],
                        filterMultiple: false
                    },
                   
                    {
                        title: "创建时间",
                        width: 180,
                        key: "ct_create_time",
                        filterType: "dateTime",
                        sortable: "custom"
                    },
                    {
                        title: "操作",
                        key: "action",
                        width: 80,
                        align: "center",
                        able: '禁止编辑',
                        render: (h, params) => {
                            return h("div", [
                               
                                h(
                                    "Button", {
                                        props: {
                                            type: "primary",
                                            size: "small"
                                        },
                                        on: {
                                            click: () => {
                                                this.$router.push(
                                                    "/Manage/System/custom-theme/login-page-edit?id=" +
                                                    params.row.ct_id
                                                );
                                            }
                                        }
                                    },
                                    "编辑"
                                )
                            ]);
                        }
                    }
                ],
                data: [],
                btnGroup: [{
                    key: "delBtn",
                    text: "删除所选",
                    type: "primary",
                    url: "/Manage/System/custom-theme/login-page/del",
                    isShow: true,
                    icon: "trash-a",
                    loading: false,
                    able: '禁止删除',
                    actionText: "确定要删除所选吗?"
                }],
                page: {
                    total: 0,
                    current: 1,
                    pageSize: 20
                }
            },
            QueryModel: {}
        };
    },
    components: {
        ManageTable
    },
    created: function () {
        this.CurUserInfo = AppFrame.UserInfo.getUserInfo();
        this.setDefaultData();
        this.find();
    },
    watch: {
        $route: function () {
            //当路由改变时
            this.setDefaultData();
            this.find();
        }
    },
    methods: {
        setDefaultData: function () {
            this.tableData.page.current = Number(this.$route.query.CurPage) || 1;
            this.tableData.page.pageSize = Number(this.$route.query.PageSize) || 20;
        },

        find: function () {
            try {
                let self = this;
                let PostData = {};
                if (this.$route.query) PostData = this.$route.query;
                PostData.CurPage = this.tableData.page.current;
                PostData.PageSize = this.tableData.page.pageSize;
                AppFrame.Http.Post("/manage-api/System/custom-theme/login-page/getItems", PostData).then(function (Ret) {
                        //alert(JSON.stringify(Ret.Data.OrgStruct));
                        self.tableData.page.total = Ret.Data.RsCount;
                        self.tableData.page.current = Ret.Data.CurPage;
                        self.tableData.page.pageSize = Ret.Data.PageSize;

                        //----填充列的过滤属性
                        self.tableData.columns.forEach(function (col) {
                            if (col.key === "iframe_orgstruct.OS_Name") {
                                col.filterOptions.splice(0, col.filterOptions.length);
                                col.filterOptions = Ret.Data.OrgStruct;
                            }
                        });
                        //------------------
                        self.tableData.data.splice(0, self.tableData.data.length);
                        Ret.Data.DataList.forEach(function (item) {
                            item.ct_create_time = moment(item.ct_create_time).format("YYYY-MM-DD hh:mm:ss");
                            self.tableData.data.push(item);
                        });
                    })
                    .catch(function (err) {
                        console.log(err)
                        self.$Message.error(JSON.stringify(err));
                    });
            } catch (err) {
                console.log(err);
            }
        }
    }
};
</script>
